package com.ruoyi.web.controller.system;

import java.util.List;

import com.ruoyi.system.domain.AdminPrizeRecord;
import com.ruoyi.system.service.IAdminPrizeRecordService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.AdminBetStatistics;
import com.ruoyi.system.service.IAdminBetStatisticsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 下注统计Controller
 * 
 * @author ruoyi
 * @date 2021-10-21
 */
@RestController
@RequestMapping("/system/betStatistics")
public class AdminBetStatisticsController extends BaseController
{
    @Autowired
    private IAdminBetStatisticsService adminBetStatisticsService;

    @Autowired
    private IAdminPrizeRecordService iAdminPrizeRecordService;

    /**
     * 查询下注统计列表
     */
    @PreAuthorize("@ss.hasPermi('system:betStatistics:list')")
    @GetMapping("/list")
    public TableDataInfo list(AdminBetStatistics adminBetStatistics)
    {
        AdminPrizeRecord notPrizeRecord = iAdminPrizeRecordService.selectAdminPrizeRecordByPrizeTime();
        startPage();
        adminBetStatistics.setPeriod(notPrizeRecord.getPeriod());
        List<AdminBetStatistics> list = adminBetStatisticsService.selectAdminBetStatisticsList(adminBetStatistics);
        return getDataTable(list);
    }

    /**
     * 导出下注统计列表
     */
    @PreAuthorize("@ss.hasPermi('system:betStatistics:export')")
    @Log(title = "下注统计", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(AdminBetStatistics adminBetStatistics)
    {
        List<AdminBetStatistics> list = adminBetStatisticsService.selectAdminBetStatisticsList(adminBetStatistics);
        ExcelUtil<AdminBetStatistics> util = new ExcelUtil<AdminBetStatistics>(AdminBetStatistics.class);
        return util.exportExcel(list, "betStatistics");
    }

    /**
     * 获取下注统计详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:betStatistics:query')")
    @GetMapping(value = "/{littleCommand}")
    public AjaxResult getInfo(@PathVariable("littleCommand") String littleCommand)
    {
        return AjaxResult.success(adminBetStatisticsService.selectAdminBetStatisticsById(littleCommand));
    }

    /**
     * 新增下注统计
     */
    @PreAuthorize("@ss.hasPermi('system:betStatistics:add')")
    @Log(title = "下注统计", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AdminBetStatistics adminBetStatistics)
    {
        return toAjax(adminBetStatisticsService.insertAdminBetStatistics(adminBetStatistics));
    }

    /**
     * 修改下注统计
     */
    @PreAuthorize("@ss.hasPermi('system:betStatistics:edit')")
    @Log(title = "下注统计", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AdminBetStatistics adminBetStatistics)
    {
        return toAjax(adminBetStatisticsService.updateAdminBetStatistics(adminBetStatistics));
    }

    /**
     * 删除下注统计
     */
    @PreAuthorize("@ss.hasPermi('system:betStatistics:remove')")
    @Log(title = "下注统计", businessType = BusinessType.DELETE)
	@DeleteMapping("/{littleCommands}")
    public AjaxResult remove(@PathVariable String[] littleCommands)
    {
        return toAjax(adminBetStatisticsService.deleteAdminBetStatisticsByIds(littleCommands));
    }
}
